<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            width: 500px;
            height: 500px;
            margin: 50px auto;
        }
        .cont{
            width: 400px;
            height: 400px;
            border: 5px solid #000;
            background: #ccc;
            color: rgb(177, 14, 14);
            font-size: 360px;
            font-weight: 900;
            line-height: 400px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="cont">A</div>
        <div class="cont2">
            正确：<input type="text" class="txt" value="0">
        </div>

    </div>
</body>
</html>
<script src="../word2/day01/js/lodash.js"></script>
<script>
    
    const cont = document.querySelector('.cont')
    const txt = document.querySelector('.txt')

    let arr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
    let sum1 = 0;
    document.addEventListener('keydown',e => {
        // console.log(e.key);
        const str = cont.innerText;
        // console.log('e.key',e.key);
        // console.log(str.toLocaleLowerCase());
        if(e.key === str.toLocaleLowerCase()){
            // console.log("111");
            let sum = _.sample(arr)
            cont.innerText = sum

            sum1 += 1;
            txt.value = sum1

        }else{
            alert(`得分为：${txt.value},成功按对了${txt.value}个`);
            sum1 = 0;
            txt.value = sum1
        }
    })
</script>